<template>
  <div class="top">
    <div class="name">{{ item.name }}</div>
    <div class="manager">{{ item.manager }}</div>
    <el-dropdown trigger="click" @command="commandEvent">
      <span class="el-dropdown-link">
        操作<i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="add">添加</el-dropdown-item>
        <el-dropdown-item v-if="!isTop" command="look">查看</el-dropdown-item>
        <el-dropdown-item v-if="!isTop" command="del">删除</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => ({})
    },
    isTop: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    commandEvent (command) {
      switch (command) {
        case 'add':
          this.$bus.$emit('addDialog', true, this.item)
          break
        case 'look':
          break
        case 'del':
          break
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.top {
  display: flex;
  justify-content: center;
  padding: 10px 0;
  .name {
    flex: 1;
  }
  .manager {
    margin-right: 25px;
  }
}
</style>
